<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>作业2</title>
    <style>
        *{margin: 10px;padding: 10px;}
        div{width: 100px;height: 100px;}
        #div1{background-color: darkorchid}
        #div2{background-color: plum}
    </style>
    <script>
        window.onload=function() {
            document.getElementById("btn1").addEventListener("click", function () {
                document.getElementById("div1").style.display="block";
                document.getElementById("div2").style.display="none";
            });
            document.getElementById("btn2").addEventListener("click", function () {
                document.getElementById("div1").style.display="none";
                document.getElementById("div2").style.display="block";
            });
            document.getElementById("btn3").addEventListener("click", function () {
                document.getElementById("div1").style.display="block";
                document.getElementById("div2").style.display="block";
            });
        }
    </script>
</head>
<body>
<button id="btn1">按钮1</button><button id="btn2">按钮2</button><button id="btn3">刷新</button>
<div>
    <div id="div1">div1</div>
    <div id="div2">div2</div>
</div>
</body>
</html>